﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using SalesSys.Comm.Utility;
using SalesSys.DAL.Models;

namespace SalesSys.Site.Models
{
    public class EmployeeDto
    {

        public Employee ToEntity(Employee entity=null)
        {
            if (entity==null)
            {
                entity = new Employee();
            }
          
            entity.Birthday = Birthday;
            entity.CreateTime = CreateTime;
            entity.IDCard = IDCard;
            entity.IsConfirm = IsConfirm;
            entity.IsLeave = IsLeave;
            entity.IsLock = IsLock;
            entity.LoginName = LoginName;
           // entity.LoginPwd = LoginPwd;
            entity.Name = Name;
            entity.Phone = Phone;
            entity.Roles = Roles;
            entity.Offices = Offices;
            entity.Token = Token;
            return entity;
        }
        /// <summary>
        /// 返回接口实体
        /// </summary>
        /// <param name="entity"></param>
        public void ToDto(Employee entity = null)
        {
            Birthday = entity.Birthday;
            CreateTime = entity.CreateTime;
            IDCard = entity.IDCard;
            IsConfirm = entity.IsConfirm;
            IsLeave = entity.IsLeave;
            IsLock = entity.IsLock;
            LoginName = entity.LoginName;
            // LoginPwd = LoginPwd;
            Name = entity.Name;
            Phone = entity.Phone;
            Roles = entity.Roles;
            Offices = entity.Offices;
            Token = entity.Token;
        }
        /// <summary>
        /// Token,唯一标识
        /// </summary>
        public string Token { get; set; }

        /// <summary>
        /// 职务,简单管理,参见：OfficesConst
        /// </summary>
        public string Offices { get; set; }

        /// <summary>
        /// 编号
        /// </summary>
        public Guid? Id { get; set; }
        //[StringLength(15,MinimumLength=6,ErrorMessage="登录名必须6~15位")]
        // [RegularExpression(RegexConst.LoginName,ErrorMessage= "用户名必须以字母开头，后跟字母或下划线")]

        /// <summary>
        /// 登录名
        /// </summary>
        public string LoginName { get; set; }

        /// <summary>
        /// 登录密码
        /// </summary>
        [StringLength(15, MinimumLength = 6, ErrorMessage = "密码必须6~15位")]
        public string LoginPwd { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreateTime { get; set; }
        /// <summary>
        /// 创建人
        /// </summary>
        public virtual Guid? CreaterId { get; set; }
        /// <summary>
        /// 是否确认
        /// </summary>
        public bool IsConfirm { get; set; }

        /// <summary>
        /// 角色
        /// </summary>
        public string Roles { get; set; }

        /// <summary>
        /// 姓名
        /// </summary>
        [Required(ErrorMessage = "名称不能为空")]
        [StringLength(15, MinimumLength = 2, ErrorMessage = "长度必须2~15位")]
        public string Name { get; set; }

        /// <summary>
        /// 身份证
        /// </summary>
        [RegularExpression(RegexConst.IdCard, ErrorMessage = "身份证格式不正确")]
        public string IDCard { get; set; }

        /// <summary>
        /// 生日
        /// </summary>
        public DateTime? Birthday { get; set; }

        /// <summary>
        /// 手机号码
        /// </summary>
        [RegularExpression(RegexConst.CellPhone, ErrorMessage = "手机号码格式不正确")]
        public string Phone { get; set; }

        /// <summary>
        /// 是否离职
        /// </summary>
        public bool IsLeave { get; set; }

        /// <summary>
        /// 是否锁定
        /// </summary>
        public bool IsLock { get; set; }

        /// <summary>
        /// 所在部门
        /// </summary>
        public virtual Guid? DepartmentId { get; set; }
    }
}